今天好累,直接上題目
題號:36 標題:Valid Sudoku 難度:Medium
Determine if a 9 x 9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules:
Each row must contain the digits 1-9 without repetition.
Each column must contain the digits 1-9 without repetition.
Each of the nine 3 x 3 sub-boxes of the grid must contain the digits 1-9 without repetition.
Note:
A Sudoku board (partially filled) could be valid but is not necessarily solvable.
Only the filled cells need to be validated according to the mentioned rules.

Explanation: Same as Example 1, except with the 5 in the top left corner being modified to 8. Since there are two 8's in the top left 3x3 sub-box, it is invalid.
Constraints:
board.length == 9
board[i].length == 9
board[i][j] is a digit 1-9 or '.'.
我的程式碼
bool isValidSudoku(char** board, int boardSize, int* boardColSize){
    int check[9] = {1,1,1,1,1,1,1,1,1};
    int i=0,j=0;
    for(i=0;i<9;i++){
        for(j=0;j<9;j++){
            if(board[i][j] == '.'){
                continue;
            }else if(check[(board[i][j]-49)] == 0){
                    printf("first %d,%d",i,j);
                    return false;
            }else{
               check[board[i][j]-49] = 0; 
            }
        }
        for(j=0;j<9;j++){
           check[j] = 1; 
        } 
    }
    
    for(j=0;j<9;j++){
        for(i=0;i<9;i++){
            if(board[i][j] == '.'){
                continue;
            }else if(check[board[i][j]-49] == 0){
                printf("second %d,%d",i,j);    
                return false;
            }else{
               check[board[i][j]-49] = 0; 
            }
        }
        for(i=0;i<9;i++){
           check[i] = 1; 
        } 
    }
    
  
    int a,b;
    
    for(a=0;a<=6;a=a+3){
        for(b=0;b<=6;b=b+3){
            for(i=a;i<a+3;i++){
                for(j=b;j<b+3;j++){
                    if(board[i][j] == '.'){
                        continue;
                    }else if(check[board[i][j]-49] == 0){
                        printf("#3 %d,%d",i,j);
                        return false;
                    }else{
                         check[board[i][j]-49] = 0; 
                    }
                }
            }
            
            for(i=0;i<9;i++){
                check[i] = 1;
            }
        }
    }
DAY11心得
這題很快,我好累,明年的我大概也會想不開來參賽,但要上班還要拼命30天,真的好痛苦阿![]()